home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
7_5.lha
/
7_5
/
7_5bline.c
< prev
next >
Wrap
Text File
|
1993-08-08
|
724b
|
31 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
/ Exercise 7.5
/ rectangle derived from a line
lass line : public rectangle
point &w() { return sw; }
point &e() { return ne; }
ublic:
point north()
{ return point((w().x+e().x)/2,
e().y<w().y?w().y:e().y); }
point east();
point south()
{ return point((w().x+e().x)/2,
e().y<w().y?e().y:w().y); }
point west();
void move(int a, int b)
{ w().x += a; w().y += b;
e().x += a; e().y += b; }
void draw() { put_line(w(),e()); }
line(point a, point b) : (a, b) { }
line(point a, int l) :
( point(a.x+l-1,a.y), a) { }
;